home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Games / NetHack 3.1.3 / source / sys / mac / macunix.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-01  |  1.0 KB  |  55 lines  |  [TEXT/R*ch]

  1. /*    SCCS Id: @(#)macunix.c    3.1    90/22/02
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5. /* This file collects some Unix dependencies */
  6.  
  7. #include "hack.h"
  8. #include <fcntl.h>
  9.  
  10. int FDECL(uptodate, (int));
  11. void FDECL(regularize,(char *));
  12. void NDECL(getlock);
  13.  
  14.  
  15. int
  16. uptodate(int fd)
  17. {
  18. #if defined(applec)
  19. # pragma unused(fd)
  20. #endif
  21.     return(1);
  22. }
  23.  
  24.  
  25. void
  26. regularize(char *s)
  27. {
  28.     register char *lp;
  29.  
  30.     while((lp=index(s, '.')) || (lp=index(s, ':')) )
  31.         *lp = '_';
  32. }
  33.  
  34.  
  35. void
  36. getlock( void )
  37. {
  38.     int fd ;
  39.     int pid = getpid() ; /* Process Serial Number ? */
  40.  
  41.     set_levelfile_name ( lock , 0 ) ;
  42.  
  43.     if ( ( fd = open ( lock , O_RDWR | O_EXCL | O_CREAT , LEVL_TYPE ) ) == -1 ) {
  44.         raw_printf ( "Could not lock the game %s." , lock ) ;
  45.         panic ( "Another game in progress ?" ) ;
  46.     }
  47.  
  48.     if ( write ( fd , ( char * ) & pid , sizeof ( pid ) ) != sizeof ( pid ) ) {
  49.         raw_printf ( "Could not lock the game %s." , lock ) ;
  50.         panic ( "Disk Locked ?" ) ;
  51.     }
  52.  
  53.     close ( fd ) ;
  54. }
  55.